var inflate = require('inflation')
var raw = require('raw-body')

const types = [
    'application-json'
];

const options = {
    limit: '1024'
}

function parseJson(req) {
    const len = req.headers['content-length'];
    const encoding = req.headers['content-encoding'] || 'identity';
}


function bodyParser(ctx, next) {
    const { req, response } = ctx;
    response.set('Content-Type', 'application/json');

    return new Promise(resolve => {
        raw(inflate(req), '', function (err, string) {
            if (string) {
                ctx.request.body = string;
            }
            resolve(next());
        });
    });
}

module.exports = bodyParser;